﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    xmlns:c4f="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    x:Class="Wulong.Phone.Qiushi.Views.MainView" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False"
    Style="{StaticResource TransitionPageStyle}">
    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="SectionListStyle" TargetType="ListBox">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeExtraLarge}"/>
            <Setter Property="Margin" Value="12,17,0,28"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="Padding" Value="5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <!--Pivot Control-->

        <controls:Panorama Grid.Row="0" x:Name="Items" Title="{Binding AppI18N.App_Title, Source={StaticResource ls}}" Background="{Binding BackgroundImage}">
            <controls:PanoramaItem x:Name="NaviListPage" Header="{Binding AppI18N.VM_Main_Category, Source={StaticResource ls}}">
                <ListBox x:Name="NavigateToQiushiListView" SelectedIndex="{Binding NaviSelectedIndex, Mode=TwoWay}" Style="{StaticResource SectionListStyle}">
                    <ListBoxItem Content="{Binding AppI18N.VM_QiushiSection_Latest, Source={StaticResource ls}}"/>
                    <ListBoxItem Content="{Binding AppI18N.VM_QiushiSection_8hrs, Source={StaticResource ls}}"/>
                    <ListBoxItem Content="{Binding AppI18N.VM_QiushiSection_24hrs, Source={StaticResource ls}}"/>
                    <ListBoxItem Content="{Binding AppI18N.VM_QiushiSection_Picstory, Source={StaticResource ls}}"/>
                </ListBox>
            </controls:PanoramaItem>
            <controls:PanoramaItem x:Name="PictureListPage" Orientation="Horizontal">
                <controls:PanoramaItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding AppI18N.VM_Main_Pcistory, Source={StaticResource ls}}"/>
                        <c4f:RoundButton Margin="5" VerticalAlignment="Center" x:Name="RefreshPicList" ImageSource="/images/refresh.png" Content="{Binding AppI18N.V_Main_AppBar_Refresh, Source={StaticResource ls}}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="RefreshPicList" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </c4f:RoundButton>
                    </StackPanel>
                </controls:PanoramaItem.Header>
                <ItemsControl x:Name="PicstoryList">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Button x:Name="ViewPicture" Background="Transparent" BorderThickness="0" Padding="0" cal:Message.Attach="[Event Click]=[Action ViewPicture($this)]" Height="160">
                                <Image MaxHeight="160" MaxWidth="160" Margin="8" HorizontalAlignment="Left" VerticalAlignment="Top" >
                                	<Image.Source>
                                		<BitmapImage UriSource="{Binding ImageUrl}" CreateOptions="BackgroundCreation"/>                    	
									</Image.Source>
								</Image>
                            </Button>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel Height="400" Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </controls:PanoramaItem>
            <controls:PanoramaItem x:Name="SettingsPage" Header="{Binding AppI18N.VM_Main_Settings, Source={StaticResource ls}}">
                <StackPanel x:Name="SettingsPanel" Grid.Row="0" Grid.ColumnSpan="2" Margin="12,17,0,28" Width="440"  >
                    <toolkit:ListPicker x:Name="SaveLangSetting" 
                                Header="{Binding Path=AppI18N.V_Settings_Lang_Select_Header, Source={StaticResource ls}}"                                 
                                SelectedIndex="{Binding SettingLangSelectedIndex, Mode=TwoWay}"
                                >
                        <toolkit:ListPickerItem Content="{Binding Path=AppI18N.V_Settings_Lang_Select_Option_Auto, Source={StaticResource ls}}"/>
                        <toolkit:ListPickerItem Content="{Binding Path=AppI18N.V_Settings_Lang_Select_Option_Chinese, Source={StaticResource ls}}"/>
                        <toolkit:ListPickerItem Content="{Binding Path=AppI18N.V_Settings_Lang_Select_Option_English, Source={StaticResource ls}}"/>
                    </toolkit:ListPicker>
                    
                </StackPanel>
            </controls:PanoramaItem>
        </controls:Panorama>
        <Grid Grid.Row="0"
                      Visibility="{Binding IsBusy, 
                            Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock Grid.Row="0" Text="{Binding Path=AppI18N.App_Loading, Source={StaticResource ls}}" 
                               Style="{StaticResource LoadingStyle}"/>
            <toolkit:PerformanceProgressBar IsIndeterminate="{Binding IsBusy}"
                                 VerticalAlignment="Top" 
                                 IsTabStop="True"
                                 Grid.Row="0" />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>